/*     */ package com.infoservice.schedule.generator;
/*     */ 
/*     */ import com.infoservice.schedule.Constant;
/*     */ import com.infoservice.schedule.po.pos.TaskPO;
/*     */ import com.infoservice.schedule.util.TaskUtils;
/*     */ import java.util.Calendar;
/*     */ import java.util.Date;
/*     */ 
/*     */ public class GenYearTask extends TaskGenerator
/*     */ {
/*     */   public GenYearTask(TaskPlanInfo tpInfo, TaskPO tk)
/*     */   {
/*  35 */     super(tpInfo, tk);
/*     */   }
/*     */ 
/*     */   public long getDelayTime()
/*     */   {
/*  43 */     Date nextDate = getNextExcTime();
/*  44 */     Calendar cur = TaskUtils.getCalendar();
/*  45 */     return nextDate.getTime() - cur.getTimeInMillis() < Constant.TASK_GEN_AHEAD_TIME ? 0L : nextDate.getTime() - cur.getTimeInMillis() - Constant.TASK_GEN_AHEAD_TIME;
/*     */   }
/*     */ 
/*     */   public long getPeriodTime()
/*     */   {
/*  54 */     return getInterval();
/*     */   }
/*     */ 
/*     */   public void run()
/*     */   {
/*  62 */     genTask();
/*     */   }
/*     */ 
/*     */   public Date getNextExcTime()
/*     */   {
/*  70 */     Calendar cur = TaskUtils.getCalendar();
/*  71 */     Date planStartTime = null;
/*  72 */     if (this.tk == null) {
/*  73 */       Calendar start = TaskUtils.getCalendar();
/*  74 */       String[] startTime = this.tpInfo.getPlanStart().split(":");
/*  75 */       start.set(11, Integer.parseInt(startTime[0]));
/*  76 */       start.set(12, Integer.parseInt(startTime[1]));
/*     */ 
/*  78 */       String[] pattern = this.tpInfo.getPlanPattern().split("-");
/*     */ 
/*  80 */       start.set(2, Integer.parseInt(pattern[0]) - 1);
/*  81 */       start.set(5, Integer.parseInt(pattern[1]));
/*     */ 
/*  83 */       planStartTime = start.getTime();
/*  84 */       if (planStartTime.getTime() >= cur.getTimeInMillis())
/*  85 */         return planStartTime;
/*     */     } else {
/*  87 */       planStartTime = this.tk.getPlanStartTime();
/*  88 */       if (planStartTime.getTime() >= cur.getTimeInMillis())
/*  89 */         return new Date(planStartTime.getTime() + getInterval());
/*     */     }
/*  91 */     int times = (int)((cur.getTimeInMillis() - planStartTime.getTime()) / getInterval());
/*  92 */     times++;
/*  93 */     return new Date(planStartTime.getTime() + times * getInterval());
/*     */   }
/*     */ 
/*     */   public void removeTaskPlan()
/*     */   {
/* 101 */     cancel();
/*     */   }
/*     */ 
/*     */   public int getIgnoreTimes()
/*     */   {
/* 109 */     Calendar cur = TaskUtils.getCalendar();
/* 110 */     Date planStartTime = null;
/* 111 */     if (this.tk == null) {
/* 112 */       Calendar start = TaskUtils.getCalendar();
/* 113 */       String[] startTime = this.tpInfo.getPlanStart().split(":");
/* 114 */       start.set(11, Integer.parseInt(startTime[0]));
/* 115 */       start.set(12, Integer.parseInt(startTime[1]));
/*     */ 
/* 117 */       String[] pattern = this.tpInfo.getPlanPattern().split("-");
/*     */ 
/* 119 */       start.set(2, Integer.parseInt(pattern[0]) - 1);
/* 120 */       start.set(5, Integer.parseInt(pattern[1]));
/*     */ 
/* 122 */       planStartTime = start.getTime();
/* 123 */       if (cur.getTimeInMillis() < planStartTime.getTime()) {
/* 124 */         return 0;
/*     */       }
/* 126 */       long times = (cur.getTimeInMillis() - planStartTime.getTime()) / getInterval();
/* 127 */       return (int)times + 1;
/*     */     }
/*     */ 
/* 130 */     planStartTime = this.tk.getPlanStartTime();
/* 131 */     if (cur.getTimeInMillis() < planStartTime.getTime()) {
/* 132 */       return 0;
/*     */     }
/* 134 */     long times = (cur.getTimeInMillis() - planStartTime.getTime()) / getInterval();
/* 135 */     return (int)times;
/*     */   }
/*     */ 
/*     */   public void setTaskPO(Date planStartTime)
/*     */   {
/* 145 */     if (this.tk == null) {
/* 146 */       this.tk = new TaskPO();
/*     */     }
/* 148 */     this.tk.setPlanStartTime(planStartTime);
/*     */   }
/*     */ 
/*     */   public Date getEndDate()
/*     */   {
/* 157 */     Calendar end = TaskUtils.getCalendar();
/* 158 */     String[] startTime = this.tpInfo.getPlanEnd().split(":");
/* 159 */     end.set(11, Integer.parseInt(startTime[0]));
/* 160 */     end.set(12, Integer.parseInt(startTime[1]));
/*     */ 
/* 162 */     String[] pattern = this.tpInfo.getPlanPattern().split("-");
/*     */ 
/* 164 */     end.set(2, Integer.parseInt(pattern[0]) - 1);
/* 165 */     end.set(5, Integer.parseInt(pattern[1]));
/* 166 */     return end.getTime();
/*     */   }
/*     */ 
/*     */   public Date getStartDate()
/*     */   {
/* 175 */     Calendar start = TaskUtils.getCalendar();
/* 176 */     String[] startTime = this.tpInfo.getPlanStart().split(":");
/* 177 */     start.set(11, Integer.parseInt(startTime[0]));
/* 178 */     start.set(12, Integer.parseInt(startTime[1]));
/*     */ 
/* 180 */     String[] pattern = this.tpInfo.getPlanPattern().split("-");
/*     */ 
/* 182 */     start.set(2, Integer.parseInt(pattern[0]) - 1);
/* 183 */     start.set(5, Integer.parseInt(pattern[1]));
/* 184 */     return start.getTime();
/*     */   }
/*     */ 
/*     */   public long getInterval()
/*     */   {
/* 191 */     long days = Calendar.getInstance().getActualMaximum(6);
/* 192 */     return days * 86400000L;
/*     */   }
/*     */ }

/* Location:           D:\Workspace\Work\ASMP_DE\lib\frame3\InfoSchedule_1.0.03.jar
 * Qualified Name:     com.infoservice.schedule.generator.GenYearTask
 * JD-Core Version:    0.6.0
 */